package haxeframe.physics;

class Material
{
	private var _name:String;
	private var _density:Float;
	private var _friction:Float;
	private var _restitution:Float;
	private var _config:Xml;
	
	
	public function new(config:Xml)
	{
		_config = config;
	}

	public static function Material()
	{
	}

	public function init():Void
	{
		_name = "default_material";
		_density = 1;
		_friction = 0.5;
		_restitution = 0.5;
		
		if (_config.exists('name')) _name = _config.get('name');
		if (_config.exists('density')) _density = Std.parseFloat(_config.get('density'));
		if (_config.exists('friction')) _friction = Std.parseFloat(_config.get('friction'));
		if (_config.exists('restitution')) _restitution = Std.parseFloat(_config.get('restitution'));
	}
	
	public function getCopy():Material
	{
		var material:Material = new Material(_config);
		return material;
	}
	
	public var name(get_name,never) : String;

	public function get_name():String
	{
		return _name;
	}
	
	public var density(get_density,never) : Float;

	public function get_density():Float
	{
		return _density;
	}
	
	public var friction(get_friction,never) : Float;

	public function get_friction():Float
	{
		return _friction;
	}
	
	
	public var restitution(get_restitution,never) : Float;

	public function get_restitution():Float
	{
		return _restitution;
	}
	
}